// 房源类型
const HomeTypeEnum = {
  DECENTRALIZED: 1,
  CENTRALIZED: 2,
  properties: {
    0: { type: 0, text: '全部' },
    1: { type: 1, text: '分散式' },
    2: { type: 2, text: '集中式' }
  }
}

const faceFileApi =
    process &&
    process.env &&
    process.env.NODE_ENV === 'production' &&
    process.env.ENV === 'online'
      ? 'https://saasfile.dding.net'
      : 'https://qa-saas.dding.net:8016' // 线上环境api一律使用绝对地址

const FunctionCode = [ // D3门锁的功能码
  {
    name: '密码清空码',
    value: '04'
  },
  {
    name: '反锁解除码',
    value: '08'
  },
  {
    name: '时间修改码',
    value: '05'
  }
]

const certificates = {
  1: '居民身份证',
  2: '其他',
  type: [
    {
      id: 1,
      name: '居民身份证'
    },
    {
      id: 2,
      name: '其他'
    }
  ]
}

const FunctionCodeToName = {
  4: '密码清空码',
  8: '反锁解除码',
  5: '时间修改码'
}

const NormalPasswordError = {
  5101: {
    description: '服务器超时'
  },
  5102: {
    description: '设备操作成功，但数据库执行出错'
  },
  5103: {
    description: '门锁在执行对应服务时出现错误'
  },
  5104: {
    description: '密码内容相似(连续四位及以上相同)'
  },
  5105: {
    description: '锁内已经存在一个该序号的密码'
  },
  5106: {
    description: '密码无效，permission内容无效'
  },
  5107: {
    description: '密码池满，无法添加新密码'
  },
  5108: {
    description: '门锁本地无此密码记录，无法响应'
  },
  5199: {
    description: '门锁本地被重置'
  }
}

// 房间类型
const RoomTypeEnum = {
  COMMON: 1,
  PUBLIC: 2,
  BUILDING: 3
}

// 设备类型
// 1网关,2门锁,3电表,4采集器,5水表网关,6冷水表,7热水表
const DeviceTypeEnum = {
  GATEWAY: 1,
  LOCK: 2,
  ELEMETER: 3,
  ELECOLLECTOR: 4,
  WATERGATEWAY: 5,
  WATERMETER_COLD: 6,
  WATERMETER_HOT: 7,
  REPEATER: 8,
  FACE_ACCESS: 10, // m2门禁
  ACCESS_CONTROL: 11, // m3门禁
  properties: {
    /** type 操作日志类型 */
    1: { id: 1, name: '网关', icon: 'gateway', type: 'gateway' },
    2: { id: 2, name: '门锁', icon: 'lock', type: 'lock' },
    3: { id: 3, name: '电表', icon: 'ammeter', type: 'elemeter' },
    4: { id: 4, name: '采集器', icon: 'ammeter-collector', type: 'elecollector' },
    5: { id: 5, name: '水表网关', icon: 'w-gateway', type: 'water_gateway' },
    6: { id: 6, name: '冷水表', icon: 'cold-w-meter', type: 'watermeter' },
    7: { id: 7, name: '热水表', icon: 'hot-w-meter', type: 'watermeter' },
    // 8: { id: 8, name: '中继器(mesh组网)', icon: 'repeater', type: 'watermeter' },
    10: { id: 10, name: '人脸门禁', icon: 'access-control', type: 'face_access' },
    11: { id: 11, name: 'M3门禁', icon: 'access-control', type: 'access_control' }
  }
}

// 网络状态
const NetState = {
  ONLINE: 1,
  OFFLINE: 2,
  properties: {
    1: { id: 1, name: '在线' },
    2: { id: 2, name: '离线' }
  }
}

// 电表付费模式
const ElemeterPayMode = {
  PREPAID: 1,
  POSTPAID: 2,
  properties: {
    1: { type: 1, text: '预付费' },
    2: { type: 2, text: '后付费' }
  }
}

// 同租人关系
const CoRenterRelations = {
  properties: [
    { value: '亲属', text: '亲属' },
    { value: '配偶', text: '配偶' },
    { value: '子女', text: '子女' },
    { value: '朋友', text: '朋友' }
  ]
}

// 异常事件
const AbnormalEvents = {
  // batteryAlarm: 1001, // 低电
  // clearBatteryAlarm: 1002, // 低电恢复
  brokenAlarm: 1003, // 防撬报警
  longTimeNoOpen: 1008, // 长时间未开门
  longTimeNoClose: 1009, // 长时间未关门
  // wrongPwdAlarm: 1004, // 密码连续错误次数大于5次
  // centerOfflineAlarm: 1006, // 4001, 网关离线
  // clearCenterOfflineAlarm: 1007, // 4002, 网关恢复在线
  // lockOfflineAlarm: 1006, // 网关子设备离线 -->(包含电表)，9410是saas判断的电表离线
  // clearLockOfflineAlarm: 1007, // 网关子设备恢复 -->(包含电表)

  // elemeterOvercomeAmount: 2003, // 超电量且电表发生了跳闸
  // elemeterOvercomeCapacity: 2004, // 超功率且发生了跳闸
  // elemeterLocalClose: 2005, // 电表本地合闸
  // elemeterTransError: 2006, // 电表485通讯异常
  // elemeterOvercomeCurrent: 2007, // 超电流且发生了跳闸
  // elemeterRemoteOpen: 2013, // 远程跳闸
  // elemeterRemoteClose: 2014, // 远程合闸

  // waterGatewayOfflineAlarm: 1006, // 3001,
  // waterGatewayOnlineAlarm: 1007, // 3002,
  // watermeterTransError: 2006, // 5001,

  // deviceUnknown: 3001,//设备未知异常，-->9199
  // elemeterLowAmount: 2008,// 电表低电量提醒，-->9409
  // elemeterServerOvercomeAmount: 2009, // 电表服务器下发超电量跳闸，-->9415

  // elemeterTransNormal: 2010,//电表通讯恢复正常,-->9416
  1001: '门锁低电',
  1002: '电量恢复',
  1003: '防撬警报',
  1004: '密码错误',

  1006: '设备离线',
  1007: '设备恢复在线',

  1008: '长时间未开门',
  1009: '长时间未锁门',

  // 2003: '超电量跳闸',
  // 2004: '超功率跳闸',
  2003: '欠费断电',
  2004: '超负荷跳闸',
  // 1008: '长时间未开门',
  // 1009: '长时间未锁门',

  // 2003: '超电量跳闸',
  // 2004: '超功率跳闸',
  2005: '本地合闸',
  2006: '接线异常',
  2007: '超负荷跳闸',

  2008: '电表低电量',
  2009: '电表服务器下发超电量跳闸',
  2010: '电表通讯恢复',

  2013: '电表断电',
  2014: '远程合闸',

  // 3001:'流量超额',
  3002: '电表欠费',
  100: '设备过保',
  5001: '水表跳变',

  4001: '门未关报警',
  4002: '非法闯入',
  4003: '防拆预警',
  4004: '消防预警',

  LOCK: [
    {
      type: 1001,
      key: 'batteryAlarm',
      description: '门锁低电'
    },
    // {
    //     type: 1002,
    //     key: 'clearBatteryAlarm',
    //     description: '电量恢复'
    // },
    {
      type: 1003,
      key: 'brokenAlarm',
      description: '门锁被撬'
    },
    // {
    //     type: 1004,
    //     key: 'wrongPwdAlarm',
    //     description: '密码错误'
    // },
    {
      type: 1006,
      key: 'lockOfflineAlarm',
      description: '设备离线'
    },
    {
      type: 1008,
      key: 'longTimeNoOpen',
      description: '长时间未开门'
    },
    {
      type: 1009,
      key: 'longTimeNoClose',
      description: '长时间未锁门'
    },
    // {
    //     type: 1007,
    //     key: 'clearLockOfflineAlarm',
    //     description: '门锁恢复在线'
    // },
    {
      type: 100,
      key: 'lock',
      description: '门锁过保'
    }
  ],
  GATEWAY: [
    {
      type: 1006,
      key: 'centerOfflineAlarm',
      description: '设备离线'
    },
    // {
    //     type: 1007,
    //     key: 'clearCenterOfflineAlarm',
    //     description: '网关恢复在线'
    // },
    {
      type: 3001,
      key: '',
      description: '流量超额'
    },
    {
      type: 100,
      key: '',
      description: '网关过保'
    }
  ],
  ELEMETER: [
    {
      type: 1006,
      key: '',
      description: '设备离线'
    },
    // {
    //     type: 1007,
    //     key: '',
    //     description: '电表恢复在线'
    // },
    // {
    //     type: 2003,
    //     key: 'elemeterOvercomeAmount',
    //     description: '电费欠费跳闸'
    // },
    // {
    //     type: 2004,
    //     key: 'elemeterOvercomeCapacity',
    //     description: '超功率跳闸'
    // },
    {
      type: 2006,
      key: '',
      description: '接线异常'
    },
    // {
    //     type: 2008,
    //     key: '',
    //     description: '电表低电量'
    // },
    // {
    //     type: 2009,
    //     key: '',
    //     description: '电表服务器下发超电量跳闸'
    // },
    // {
    //     type: 2010,
    //     key: '',
    //     description: '电表通讯恢复'
    // },
    {
      type: 2013,
      key: 'elemeterRemoteOpen',
      description: '电表断电'
    },
    // {
    //     type: 3001,
    //     key: '',
    //     description: '流量超额'
    // },
    {
      type: 3002,
      key: '',
      description: '电表欠费'
    },
    {
      type: 100,
      key: '',
      description: '电表过保'
    }
  ],
  ELECOLLECTOR: [
    {
      type: 1006,
      key: '',
      description: '设备离线'
    },
    // {
    //     type: 1007,
    //     key: '',
    //     description: '采集器恢复在线'
    // },
    {
      type: 100,
      key: '',
      description: '采集器过保'
    }
  ],
  WATERMETER_HOT: [
    {
      type: 1006,
      key: '',
      description: '设备离线'
    },
    {
      type: 2006,
      key: 'watermeterTransError',
      description: '接线异常'
    },
    {
      type: 100,
      key: '',
      description: '水表过保'
    },
    {
      type: 5001,
      key: '',
      description: '水表跳变'
    }
  ],
  WATERMETER_COLD: [
    {
      type: 1006,
      key: '',
      description: '设备离线'
    },
    {
      type: 2006,
      key: 'watermeterTransError',
      description: '接线异常'
    },
    {
      type: 100,
      key: '',
      description: '水表过保'
    },
    {
      type: 5001,
      key: '',
      description: '水表跳变'
    }
  ],
  REPEATER: [
    {
      type: 1006,
      key: '',
      description: '设备离线'
    },
    {
      type: 2006,
      key: '',
      description: '接线异常'
    },
    {
      type: 100,
      key: '',
      description: '中继器过保'
    }
  ],
  WATERGATEWAY: [
    {
      type: 1006,
      key: '',
      description: '设备离线'
    },
    // {
    //     type: 1007,
    //     key: '',
    //     description: '水表网关恢复在线'
    // },
    {
      type: 100,
      key: '',
      description: '水表网关过保'
    }
  ],
  FACE_ACCESS: [
    {
      type: 1006,
      description: '设备离线'
    },
    {
      type: 4001,
      description: '门未关报警'
    },
    {
      type: 4002,
      description: '非法闯入'
    },
    {
      type: 4003,
      description: '防拆预警'
    },
    {
      type: 4004,
      description: '消防预警'
    }
  ],
  ACCESS_CONTROL: [
    {
      type: 1006,
      key: '',
      description: '设备离线'
    },
    {
      type: 100,
      key: '',
      description: '门禁过保'
    }
  ]
}

const ServiceType = {
  1: '新装',
  2: '维修',
  3: '拆卸',
  4: '重装',

  install: 1,
  repair: 2,
  teardown: 3,
  re_install: 4
}

const TicketCountEnum = {
  delay: '延期工单',
  wait_accept: '待受理',
  accepted: '已受理',
  wait_service: '待客服处理',
  // working: '作业中',
  pending: '待派单',
  distributed: '待上门',
  change_appoint: '改约工单'
}

const ticketTags = {
  1: '延期工单',
  2: '改约工单',
  3: '签到异常',
  4: '正常签到'
}

// 工单状态
const _TicketStateInstall = {
  1: '待派单',
  3: '待上门',
  4: '待验收',
  5: '已验收',
  6: '已关闭',
  7: '待客服处理',
  8: '作业中'
}
const _TicketStateOther = {
  1: '待派单',
  2: '待上门',
  3: '待验收',
  4: '已验收',
  5: '已评价',
  6: '已关闭',
  7: '未评价',
  8: '已受理',
  9: '待受理',
  10: '待客服处理',
  11: '作业中'
}
const TicketState = {
  1: _TicketStateInstall,
  2: _TicketStateOther,
  3: _TicketStateOther,
  4: _TicketStateOther
}

/**
新装工单操作按钮
1）待派单：复制、详情、编辑和取消
2）待上门：复制、详情、编辑和取消
3）作业中：复制、详情
4）待客服处理：复制、详情
5）待验收：复制、详情，驳回和通过
6）已验收：复制、详情
7）已关闭：复制、详情

维修+重装+拆卸 工单操作按钮
1）待受理：复制、详情、编辑和取消
2）已受理：复制、详情、编辑和取消
3）待派单：复制、详情、编辑和取消
4）待上门：复制、详情、编辑和取消
5）作业中：复制、详情
6）待客服处理：复制、详情
7）待验收：复制、详情，驳回和通过
8）已验收：复制、详情
9）已关闭：复制、详情
*/
const _TicketOperateBtnsInstall = {
  1: ['复制', '详情', '编辑', '取消'], // '待派单',
  3: ['复制', '详情', '编辑', '取消'], // '待上门',
  4: ['复制', '详情', '驳回', '通过'], // '待验收',
  5: ['复制', '详情'], // '已验收',
  6: ['复制', '详情'], // '已关闭',
  7: ['复制', '详情'], // '待客服处理',
  8: ['复制', '详情'] // '作业中'
}
const _TicketOperateBtnsOther = {
  1: ['复制', '详情', '编辑', '取消'], // '待派单',
  2: ['复制', '详情', '编辑', '取消'], // '待上门',
  3: ['复制', '详情', '驳回', '通过'], // '待验收',
  4: ['复制', '详情'], // '已验收',
  5: ['复制', '详情'], // '已评价',
  6: ['复制', '详情'], // '已关闭',
  7: ['复制', '详情'], // '未评价',
  8: ['复制', '详情', '编辑', '取消'], // '已受理',
  9: ['复制', '详情', '编辑', '取消'], // '待受理',
  10: ['复制', '详情'], // '待客服处理',
  11: ['复制', '详情'] // '作业中'
}
const TicketOperateBtns = {
  1: _TicketOperateBtnsInstall,
  2: _TicketOperateBtnsOther,
  3: _TicketOperateBtnsOther,
  4: _TicketOperateBtnsOther
}

const AppointmentPeriod = {
  1: '全天',
  2: '上午',
  3: '下午'
}

const LowWarnValues = [3, 5, 8, 10]
const CountryCodes = [
  {
    country: '中国大陆+86',
    code: '86'
  },
  {
    country: '英国+44',
    code: '44'
  }
]
const FinancePaymentType = {
  1: '月结',
  2: '项目制',
  3: '先款后货'
}

const teardownReason = {
  // 1: '未交付',
  // 2: '已交付',
  // 3: '被替换',
  4: '退货',
  5: '丢失',
  6: '拆回'
  // 7: '解绑'
}

const isGoodProduct = {
  1: '是',
  2: '否'
}

const lockOpenTypes = {
  0: '机械开门',
  1: '蓝牙开门',
  2: '密码开门',
  3: '指纹开门',
  4: '蓝牙钥匙开门',
  5: '钥匙开门'
}
// 门禁操作状态
const accessOpstate = {
  11: '创建授权中',
  12: '创建授权失败',
  13: '创建授权成功',
  21: '更新授权中',
  22: '更新授权失败',
  23: '更新授权成功',
  31: '删除授权中',
  32: '删除授权失败',
  33: '删除授权成功'
}

// 门禁授权状态
const authState = {
  0: '未知',
  1: '未生效',
  2: '未生效（未下发成功）',
  3: '已生效',
  4: '已失效'
}

/** 门禁人员标签 */
const faceAccessAuthType = {
  1: '员工',
  2: '租客',
  3: '访客',
  list: [
    { id: 0, name: '全部' },
    { id: 1, name: '员工' },
    { id: 2, name: '租客' },
    { id: 3, name: '访客' }
  ]
}

// 开门统计时间段
const periodTimeData = {
  list: [
    {type: 'all', name: '全部'},
    {type: 'today', name: '今天'},
    {type: 'yesterday', name: '昨天'},
    {type: 'lastWeek', name: '本周'},
    {type: 'lastMonth', name: '本月'}
  ]
}

const chargeChannel = {
  map: {
    1: '人工充值',
    2: '微信',
    3: '支付宝',
    4: '接口充值'
  },
  list: [
    { id: 1, label: '人工充值', user: '[员工]' },
    { id: 4, label: '接口充值', user: 'system', noName: true },
    { id: 2, label: '微信', user: '[租客]' },
    { id: 3, label: '支付宝', user: '[租客]' }
  ]
}

module.exports = {
  faceAccessAuthType,
  periodTimeData,
  certificates,
  HomeTypeEnum,
  RoomTypeEnum,
  DeviceTypeEnum,
  ElemeterPayMode,
  CoRenterRelations,
  AbnormalEvents,
  NetState,
  FinancePaymentType,
  FunctionCode,
  FunctionCodeToName,

  ServiceType,
  TicketCountEnum,
  ticketTags,
  TicketState,
  TicketInstallState: TicketState[1],
  TicketRepairState: TicketState[2],
  TicketOperateBtns,

  AppointmentPeriod,
  LowWarnValues,
  NormalPasswordError,
  CountryCodes,

  teardownReason,
  isGoodProduct,

  lockOpenTypes,
  authState,
  accessOpstate,
  chargeChannel,
  faceFileApi
}
